<?php
/*
* File：导出卡密
* Author：易如意
* QQ：51154393
* Url：www.eruyi.cn
*/

require_once 'globals.php';
$type = isset($_POST['type']) ? addslashes($_POST['type']) : 'TK';
$new = isset($_POST['new']) ? addslashes($_POST['new']) : 'y';
$submit = isset($_POST['submit']) ? addslashes($_POST['submit']) : '';
if($submit){
	$sql="select * from eruyi_kami where `type`='$type' and `new`='$new'";
	$query=$db->query($sql);
	header("Content-Type: application/octet-stream");
	header("Content-Disposition: attachment; filename={$type}_kami.txt");
	echo "==============卡密开始================\r\n\r\n";
	while($rows=$db->fetch_array($query)){
		echo $rows['kami']."\r\n";
	}
	echo "\r\n\r\n==============卡密结束================";
	exit;
}else{
	require_once 'header.php';
}

?>
<form action="" method="post" id="addimg" name="addimg">
<div id="post">
<div>
    <label for="type" id="type_label">卡密类型：</label>
    <select name="type" id="type">
	  <option value="TK">天卡</option>
	  <option value="ZK">周卡</option>
	  <option value="YK">月卡</option>
	  <option value="BNK">半年卡</option>
	  <option value="NK">年卡</option>
	  <option value="YJK">永久卡</option>
	</select>
	<select name="new" id="new">
	  <option value="y">可用</option>
	  <option value="n">已用</option>
	</select>
	<input type="submit" name="submit" value="导出卡密" class="button" />
</div>
</div>
</form>
<script> 
var div = document.getElementById('out_kami'); 
div.setAttribute("class", "show"); 
</script> 
<?php 
include_once 'footer.php';
?>